﻿$(document).ready(function(){
    new CheckContent();
    setDataGridH();
});

function setDataGridH(){
    $("html").css("height","100%");
    $("body").css({
        "height":"99%",
        "margin-bottom":0,
        "margin-top":0});
    $(".header").css("margin-top",-5);
    var t = setTimeout(function(){
        var bodyH = document.body.clientHeight;
        var headerH = $(".header").outerHeight(true);
        var h2H = $("h2").outerHeight(true)*$("h2").length;
        var editBlockH =$(".editBlock").outerHeight(true);
        var pageH = $(".page").outerHeight(true);
        var bottombarH = $(".bottomtoolbar").outerHeight(true);
        if(bodyH>362){
            var dataGridH = bodyH-headerH-h2H-editBlockH-pageH-bottombarH-12;
            $(".dataGrid,.fixedH").height(dataGridH);
            $(".dataGrid,.fixedH").css("overflow-y","auto");
            var scrollbarH = $(".dataGrid,.fixedH")[0].scrollHeight-$(".dataGrid,.fixedH")[0].clientHeight;
            if(scrollbarH>0&$(".dataGrid>table").length>0){
                var tableW = $(".dataGrid>table").width()-16; //16为标准滚动条宽度
                $(".dataGrid>table").css({"width":tableW}); 
            }else if(scrollbarH>0&$(".fixedH ul").length>0){
                var liW = $("ul").width()/3-12;
                $(".fixedH li").width(liW);
            }
        }else{
            $("body").css({"overflow-y":"auto","overflow-x":"hidden"});
            $(".dataGrid").css("overflow-y","auto");
        } 
    },100);
    
}
(function(scope){
    function CheckContent(){
        var self = this;
        self._init();
    };
    $.extend(CheckContent.prototype, {
        _init: function(){
            var self = this;
            self.content ="";
            self.subBtn = $("#submitBtn");
            self.cancelBtn = $("[value='Cancel']");
            self.tr = $(".tableHover").find("tr");
            
            self._trClick();
            self._submit();
        },
        _trClick:function(){
            var self = this;
            var num = $(".dataGrid tbody").attr('show');
            if(num==undefined){num = 2;}
            self.tr.click(function(){
                $(this).find("input:radio").attr("checked","checked");
                self.content= $(this).find("td").eq(num).text();  
            }); 
        },
        _submit:function(){
            var self = this;
            var title = $("title").text();
            var title_h= title+"_hidden";
            self.subBtn.click(function(){  
                  
                popdown(title);
            });
            self.cancelBtn.click(function(){ 
                popdown(title);
            });
        }
    });
    scope.CheckContent = CheckContent;
})(window);

